package ym.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ym.mapper.CategoryTypeMapper;
import ym.pojo.CategoryType;
import ym.service.CategoryTypeService;

import java.util.List;

@Service
@Transactional
public class CategoryTypeServiceImpl implements CategoryTypeService {
    @Autowired
    private CategoryTypeMapper categoryTypeMapper;

    @Override
    public void add(CategoryType categoryType) {
        categoryTypeMapper.insert(categoryType);
    }

    @Override
    public void update(CategoryType categoryType) {
        categoryTypeMapper.updateById(categoryType);
    }

    @Override
    public void delete(Integer id) {
        categoryTypeMapper.deleteById(id);
    }

    @Override
    public CategoryType findById(Integer id) {
        return categoryTypeMapper.selectById(id);
    }

    @Override
    public List<CategoryType> findAll() {
        return categoryTypeMapper.selectList(null);
    }
    @Override
    public Page<CategoryType> search(int page, int size) {
        return categoryTypeMapper.selectPage(new Page<>(page, size), null);
    }

}
